﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GEA
{
    public partial class frmReports : Form
    {
        clDatabase dal = new clDatabase();
        string id_e;

        public frmReports()
        {
            InitializeComponent();
        }

        public frmReports(string ent)
        {
            InitializeComponent();
            id_e = ent;
        }

        private void frmReports_Load(object sender, EventArgs e)
        {
            Load_DGV(GlobalVar.GlobalEntreposto,"");
            dateTimePicker1.Value = DateTime.Now;

            this.Padding = new System.Windows.Forms.Padding(5, 20, 5, 50);
        }

        public void Load_DGV(string id_e, string like)
        {

            dataGridView1.DataSource = dal.Get_Report(id_e,"");
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
            dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Bold);
            //dataGridView1.Columns[0].HeaderCell.Style.Font = new Font("Arial", 14F, FontStyle.Bold, GraphicsUnit.Pixel);
            if (dataGridView1.RowCount > 0)
            {
                dataGridView1.Columns["id_processo"].HeaderText = "PROCESSOS".ToUpper();
                dataGridView1.Columns["id_du"].HeaderText = "DU's".ToUpper();
                dataGridView1.Columns["id_referencia"].HeaderText = "REFERÊNCIAS".ToUpper();
            }
            else
            {
                ((mdiMain)this.ParentForm).tsReport1.Enabled = false;
                ((mdiMain)this.ParentForm).tsReport2.Enabled = false;
                ((mdiMain)this.ParentForm).tsReport3.Enabled = false;
                ((mdiMain)this.ParentForm).tsReport4.Enabled = false;
            }
        }

        private void tbPesqProcesso_TextChanged(object sender, EventArgs e)
        {
            dataGridView1.DataSource = dal.Get_Report(GlobalVar.GlobalEntreposto, tbPesqProcesso.Text);
        }


    }
}
